*****************************************************************************************************
***Replication Files: Electoral Rules, Women's Representation and the Qualification of Politicians***
*****************************************************************************************************

**************
***Appendix***
**************

***TABLES

*TABLE A1 - DESCRIPTION OF DATA SOURCES

*TABLE A2 - LIKELIHOOD OF ELECTION

use "~/Downloads/2013_candidate_elected.dta", clear 
cd "~/Downloads"

probit eletto i.safe_seat##i.male age i.edu_level pol_spectrum dm_constit dyn_subnat, vce(cluster num_district) //table 9
* outreg2 using voterbias, tex replace ctitle("Safe") title("Likelihood of Election, 2013") addstat(Pseudo R2, e(r2_p))  dec(3) pdec(3)

probit eletto i.unc_seat##i.male age i.edu_level pol_spectrum dm_constit dyn_subnat, vce(cluster num_district)
* outreg2 using voterbias, tex append ctitle("Comp.") addstat(Pseudo R2, e(r2_p))  dec(3) pdec(3)

probit eletto i.impossible_seat##i.male age i.edu_level pol_spectrum dm_constit dyn_subnat, vce(cluster num_district) 
* outreg2 using voterbias, tex append ctitle("No Ch.") addstat(Pseudo R2, e(r2_p))  dec(3) pdec(3)

preserve
keep if unc_seat == 1
probit eletto i.male age i.edu_level pol_spectrum dm_constit dyn_subnat, vce(cluster num_district) 
* outreg2 using voterbias, tex append ctitle("Tight Races") addstat(Pseudo R2, e(r2_p))  dec(3) pdec(3)
restore 


*TABLE A3 - LOW/HIGH GENDER TRADITIONALISM

use "~/Downloads/1987_2013_elected_gendertrad.dta", clear 

preserve

drop if high_g_trad ==1 

reg female 1.post_reform##1.nat_subnat year i.macro_region reg_magn, vce(cluster ID)
* outreg2 using gendertrad_NEW, tex replace ctitle("LOW") title("Low vs. High Gender Traditionalism") keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Full Cntrls. YES) dec(3)
restore

preserve

drop if high_g_trad ==0 

reg female 1.post_reform##1.nat_subnat year i.macro_regions reg_magn, vce(cluster ID)
* outreg2 using gendertrad_NEW, tex append ctitle("HIGH") title("Low vs. High Gender Traditionalism") keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Full Cntrls. YES) dec(3)

restore


*TABLE A4 - EDUCATION COMPARISON CANDIDATES/ELECTED PRE/POST NORTH AND SOUTH

use "~/Downloads/1994_2011_elected.dta", clear 
cd "~/Downloads"
xtset ID year

keep if lv_new == 4
drop if edu_lev == . 
gen north = 0
replace north = 1 if macro_reg == 1
gen south = 0 
replace south = 1 if macro_reg >1 & macro_reg < 4 //exclude overseas constituencies 
replace north = . if macro_reg == 4
replace south = . if macro_reg == 4

count if post_ref == 0 
count if post_ref == 1  

count if north == 1 & post_reform == 0 //PRE TOTAL, NORTH 
count if south == 1 & post_reform == 0  //PRE TOTAL, SOUTH *DOES NOT ADD UP EXACTLY TO MAIN TEXT NUMBERS AS WE EXCLUDE OVERSEAS CONSTITUENCIES 

count if north == 1 & post_reform == 1 //POST TOTAL, NORTH 
count if south == 1 & post_reform == 1 //POST TOTAL, SOUTH  

count if north == 1 & post_reform == 0 & male == 0 //PRE NORTH FEMALE
count if north == 1 & post_reform == 0 & male == 1 //PRE NORTH MALE 
count if north == 1 & post_reform == 1 & male == 0 //POST NORTH FEMALE  
count if north == 1 & post_reform == 1 & male == 1 //POST NORTH MALE 

count if south == 1 & post_reform == 0 & male == 0 //PRE SOUTH FEMALE 
count if south == 1 & post_reform == 0 & male == 1 //PRE SOUTH MALE 
count if south == 1 & post_reform == 1 & male == 0 //POST SOUTH FEMALE 
count if south == 1 & post_reform == 1 & male == 1 //2881, POST SOUTH MALE 

//PANEL A, WOMEN
count if hi_edu == 1 & north == 1 & post_reform == 0 & male == 0 //74% NORTH PRE 
count if hi_edu == 1 & south == 1 & post_reform == 0 & male == 0 //78% SOUTH PRE
count if hi_edu == 1 & north == 1 & post_reform == 1 & male == 0 //72% NORTH POST
count if hi_edu == 1 & south == 1 & post_reform == 1 & male == 0 //75% SOUTH POST

//PANEL B, MEN 
count if hi_edu == 1 & north == 1 & post_reform == 0 & male == 1 //68% NORTH PRE 
count if hi_edu == 1 & south == 1 & post_reform == 0 & male == 1 //77% SOUTH PRE 
count if hi_edu == 1 & north == 1 & post_reform == 1 & male == 1 //69% NORTH POST 
count if hi_edu == 1 & south == 1 & post_reform == 1 & male == 1 //75% SOUTH POST 

//PANELS C AND D, NON-ELECTED VS ELECTED, 2013
use "~/Downloads/2013_candidate_elected.dta", clear 

duplicates drop lastname firstname year_birth district, force
drop if edu_level == . 

count if north == 1 & eletto == 0 
count if north == 1 & eletto == 1 
count if south == 1 & eletto == 0 
count if south == 1 & eletto == 1 

//PANEL C, WOMEN
count if north == 1 & male == 0 & eletto == 1 //NORTH WOMEN ELECTED (29%, OVERALL)
count if north == 1 & male == 0 & eletto == 0 //NORTH WOMEN NON-ELECTED (32%, OVERALL)
count if south == 1 & male == 0 & eletto == 1 //SOUTH WOMEN ELECTED (30%, OVERALL)
count if south == 1 & male == 0 & eletto == 0 //SOUTH WOMEN NON-ELECTED (30%, OVERALL)

count if north == 1 & eletto == 1 & male == 0 & hi_edu == 1 //69% NORTH ELECTED HI
count if north == 1 & eletto == 1 & male == 0 & lo_edu == 1 //31% NORTH ELECTED LO
count if south == 1 & eletto == 1 & male == 0 & hi_edu == 1 //68% SOUTH ELECTED HI
count if south == 1 & eletto == 1 & male == 0 & lo_edu == 1 //32% SOUTH ELECTED LO

count if north == 1 & eletto == 0 & male == 0 & hi_edu == 1 //72% NORTH NON-ELECTED HI
count if north == 1 & eletto == 0 & male == 0 & lo_edu == 1 //28% NORTH NON-ELECTED LO
count if south == 1 & eletto == 0 & male == 0 & hi_edu == 1 //80% SOUTH NON-ELECTED HI
count if south == 1 & eletto == 0 & male == 0 & lo_edu == 1 //20% SOUTH NON-ELECTED LO

//PANEL D, MEN
count if north == 1 & male == 1 & eletto == 1 //NORTH MEN ELECTED (71%, OVERALL)
count if north == 1 & male == 1 & eletto == 0 //NORTH MEN NON-ELECTED (68%, OVERALL)
count if south == 1 & male == 1 & eletto == 1 //SOUTH MEN ELECTED (70%, OVERALL)
count if south == 1 & male == 1 & eletto == 0 //SOUTH MEN NON-ELECTED (70%, OVERALL)

count if north == 1 & eletto == 1 & male == 1 & hi_edu == 1 //68% NORTH ELECTED HI 
count if north == 1 & eletto == 1 & male == 1 & lo_edu == 1 //32% NORTH ELECTED LO 
count if south == 1 & eletto == 1 & male == 1 & hi_edu == 1 //69% SOUTH ELECTED HI
count if south == 1 & eletto == 1 & male == 1 & lo_edu == 1 //31% SOUTH ELECTED, LO 

count if north == 1 & eletto == 0 & male == 1 & hi_edu == 1 //59% NORTH NON-ELECTED HI 
count if north == 1 & eletto == 0 & male == 1 & lo_edu == 1 //41% NORTH NON-ELECTED LO 
count if south == 1 & eletto == 0 & male == 1 & hi_edu == 1 //70% SOUTH NON-ELECTED HI 
count if south == 1 & eletto == 0 & male == 1 & lo_edu == 1 //30% SOUTH NON-ELECTED LO


*TABLE A5 - ROBUSTNESS TESTS

use "~/Downloads/1987_2013_elected.dta", clear 
cd "~/Downloads"
xtset ID year

///CHANGING CUT-OFF POINTS - FOR YEAR WHEN 1993 REFORM EVENS OUT - DIFF-IN-DIFF*
//1993
preserve
drop if year < 1993
reg female 1.post_reform##1.nat_subnat year i.macro_regions reg_magn, vce(cluster ID)
* outreg2 using NEW_Robust, tex replace ctitle("1993 Span") title("Robustness Checks") keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Full Controls, YES) nocons dec(3) pdec(3)
restore 

//1995
preserve
drop if year < 1995
reg female 1.post_reform##1.nat_subnat year i.macro_regions reg_magn, vce(cluster ID)
* outreg2 using NEW_Robust, tex append ctitle("1995 Span") keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Full Controls, YES) nocons dec(3) pdec(3)
restore 

//2000
preserve
drop if year < 2000
reg female 1.post_reform##1.nat_subnat year i.macro_regions reg_magn, vce(cluster ID)
* outreg2 using NEW_Robust, tex append ctitle("2000 Span") keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Full Controls, YES) nocons dec(3) pdec(3)
restore 

//TRUNCATING SUBNATIONAL CAREER LENGTH, TAKING OUT OUTLIERS - DIFF-IN-DIFF**
preserve 
drop if year < 1994
drop if year > 2011

drop if dyn_subnat_car > 15 //ONLY THE TOP 5% OF THE DISTRIBUTION HAVE MORE THAN 15 YEARS OF SUBNAT EXP (MAX. = 27)
reg female 1.post_reform##1.nat_subnat year i.macro_regions reg_magn, vce(cluster ID) 
* outreg2 using NEW_Robust, tex append ctitle("Outliers") keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Full Controls, YES) nocons dec(3) pdec(3)
restore 

//MUNI
preserve
drop if year < 1994
drop if year > 2011

gen nat_muni = .
replace nat_muni = 1 if lv_new == 4
replace nat_muni = 0 if lv_new == 1

gen nat_prov = .
replace nat_prov = 1 if lv_new == 4
replace nat_prov = 0 if lv_new == 2

gen nat_reg = .
replace nat_reg = 1 if lv_new == 4
replace nat_reg = 0 if lv_new == 3

reg female 1.post_reform##1.nat_muni year i.macro_regions reg_magn, vce(cluster ID)
* outreg2 using NEW_Robust, tex append ctitle("Mun1. CG") keep(1.post_reform 1.nat_muni 1.post_reform##1.nat_muni) addtext(Full Controls, YES) nocons dec(3) pdec(3)

//PROV
reg female 1.post_reform##1.nat_prov year i.macro_regions reg_magn, vce(cluster ID)
* outreg2 using NEW_Robust, tex append ctitle("Prov. CG") keep(1.post_reform 1.nat_prov 1.post_reform##1.nat_prov) addtext(Full Controls, YES) nocons dec(3) pdec(3)

//REG
reg female 1.post_reform##1.nat_reg year i.macro_regions reg_magn, vce(cluster ID)
* outreg2 using NEW_Robust, tex append ctitle("Reg. CG") keep(1.post_reform 1.nat_reg 1.post_reform##1.nat_reg) addtext(Full Controls, YES) nocons dec(3) pdec(3)
restore 

//WITH FULL REGIONAL CONTROLS
preserve
drop if year < 1994
drop if year > 2011

reg female 1.post_reform##1.nat_subnat year i.region_new reg_magn, vce(cluster ID) 
* outreg2 using NEW_Robust, tex append ctitle("Reg. Cntrls") keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Full Controls, YES) nocons dec(3) pdec(3)
restore 


*TABLE A6 - LAGS AND LEADS

preserve
drop if year < 1994
drop if year > 2011

gen lag1 = year== 2004
gen lag2 = year== 2003
gen lag3 = year== 2002
gen lag4 = year== 2001
gen lag5 = year== 2000
gen lag6 = year== 1999
gen lag7 = year== 1998
gen lag8 = year== 1997
gen lag9 = year== 1996
gen lag10 = year== 1995
gen lag11 = year== 1994

gen lead1 = year== 2006
gen lead2 = year== 2007
gen lead3 = year== 2008
gen lead4 = year== 2009
gen lead5 = year== 2010
gen lead6 = year== 2011

reg female 1.lag5##1.nat_subnat 1.lag4##1.nat_subnat 1.lag3##1.nat_subnat 1.lag2##1.nat_subnat 1.lag1##1.nat_subnat 1.post_reform##1.nat_subnat ///
1.lead1##1.nat_subnat 1.lead2##1.nat_subnat 1.lead3##1.nat_subnat ///
 year i.macro_region reg_magn, vce(cluster ID)
* outreg2 using NEW_LagLead, tex replace ctitle("Lags-Leads") title("Lags and Leads, Placebo Test") nocons dec(3) pdec(3)
restore


*TABLE A7 - 1993 REFORM

preserve
drop if year > 2001
collapse (mean) female reg_magn, by(year nat_subnat)
gen post_93 = year>= 1993
replace post_93 = 0 if post_93 == .
bysort year: egen agg_reg_magn = max(reg_magn)

reg female 1.post_93##1.nat_subnat, r
* outreg2 using NEW_1993, tex replace ctitle("Agg. OLS") title("1993 Reform") keep(1.post_93 1.nat_subnat 1.post_93##1.nat_subnat) nocons dec(3) pdec(3)

reg female 1.post_93##1.nat_subnat year, r
* outreg2 using NEW_1993, tex append ctitle("Time Trend") keep(1.post_93 1.nat_subnat 1.post_93##1.nat_subnat) nocons dec(3) pdec(3)
restore

preserve
drop if year > 2001

collapse (mean) female reg_magn , by(year nat_subnat macro_regions)
gen post_93 = year>= 1993
replace post_93 = 0 if post_93 == .
bysort year: egen agg_reg_magn = max(reg_magn)

reg female 1.post_93##1.nat_subnat year i.macro_region reg_magn, r
* outreg2 using NEW_1993, tex append ctitle("Cntrls") keep(1.post_93 1.nat_subnat 1.post_93##1.nat_subnat) nocons dec(3) pdec(3)
restore

preserve
drop if year > 2001
gen post_93 = year>= 1993

reg female 1.post_93##1.nat_subnat, vce(cluster ID)   //linear probability model
* outreg2 using NEW_1993, tex append ctitle("Ind: No Cntrls") keep(1.post_93 1.nat_subnat 1.post_93##1.nat_subnat) nocons dec(3) pdec(3)

reg female 1.post_93##1.nat_subnat year, vce(cluster ID)
* outreg2 using NEW_1993, tex append ctitle("Ind: Time") keep(1.post_93 1.nat_subnat 1.post_93##1.nat_subnat) addtext(Year FE, YES) nocons dec(3) pdec(3)

reg female 1.post_93##1.nat_subnat year i.macro_region reg_magn, vce(cluster ID)
* outreg2 using NEW_1993, tex append ctitle("Ind: Cntrls") keep(1.post_93 1.nat_subnat 1.post_93##1.nat_subnat) addtext(Year FE, YES, Ind. Controls, YES) nocons dec(3) pdec(3)
restore


*TABLE A8 - TAKING OUT CAMPANIA

preserve
drop if year < 1994
drop if year > 2011

drop if region_new == 15

collapse (mean) female reg_magn , by(year nat_subnat)

gen post_reform = year>= 2005
replace post_reform = 0 if post_reform == .

reg female 1.post_reform##1.nat_subnat, r
* outreg2 using No_Campania, tex replace keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, NO, Controls, NO) title("Electoral Reform and Female Representation: Share of Women Elected and Female Election Probability") nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year, r
* outreg2 using No_Campania, tex append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, YES, Controls, NO) nocons dec(3) pdec(3)
restore 

preserve
drop if year < 1994
drop if year > 2011

drop if region_new == 15

collapse (mean) female reg_magn , by(year nat_subnat macro_regions)

gen post_reform = year>= 2005
replace post_reform = 0 if post_reform == .

reg female 1.post_reform##1.nat_subnat year i.macro_region reg_magn, r
* outreg2 using No_Campania, tex append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, YES, Controls, YES) nocons dec(3) pdec(3)
restore 

preserve
drop if year < 1994
drop if year > 2011

drop if region_new == 15

reg female 1.post_reform##1.nat_subnat, vce(cluster ID)   
* outreg2 using No_Campania, tex append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, NO, Controls, NO) nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year, vce(cluster ID)
* outreg2 using No_Campania, tex  append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, YES, Controls, NO) nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year i.macro_region reg_magn, vce(cluster ID)
* outreg2 using No_Campania, tex append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, YES, Controls, YES) nocons dec(3) pdec(3)
restore


*TABLE A9 - REPLICATION WITHOUT SENATORS

use "~/Downloads/1987_2013_elected.dta", clear 
cd "~/Downloads"
xtset ID year

drop if region_new == 2 | region_new == 5 | region_new == 14  //get rid of VAO, TAA and MOL politicians as they used MAJ electoral system 
drop if life_senator == 1
bysort ID nat_elec_group: egen senator_new = max(senator)
drop if senator_new == 1
drop if year < 1994
drop if year > 2011

preserve

collapse (mean) female reg_magn, by(year nat_subnat)
gen post_reform = year>= 2005
replace post_reform = 0 if post_reform == .

reg female 1.post_reform##1.nat_subnat, r
* outreg2 using No_Senators, tex replace keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, NO, Controls, NO) title("Electoral Reform and Female Representation: Share of Women Elected and Female Election Probability - Senate Excluded") nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year, r
* outreg2 using No_Senators, tex append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, YES, Controls, NO) nocons dec(3) pdec(3)
restore 

preserve

collapse (mean) female reg_magn , by(year nat_subnat macro_regions)
gen post_reform = year>= 2005
replace post_reform = 0 if post_reform == .

reg female 1.post_reform##1.nat_subnat year i.macro_region reg_magn, r
* outreg2 using No_Senators, tex append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, YES, Controls, YES) nocons dec(3) pdec(3)
restore 

preserve

reg female 1.post_reform##1.nat_subnat, vce(cluster ID)   
* outreg2 using No_Senators, tex append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, NO, Controls, NO) nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year, vce(cluster ID)
* outreg2 using No_Senators, tex  append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, YES, Controls, NO) nocons dec(3) pdec(3)

reg female 1.post_reform##1.nat_subnat year i.macro_region reg_magn, vce(cluster ID)
* outreg2 using No_Senators, tex append keep(1.post_reform 1.nat_subnat 1.post_reform##1.nat_subnat) addtext(Time Trend, YES, Controls, YES) nocons dec(3) pdec(3)
restore


***TABLE A10 - RIGHT WING PARTIES 

use "~/Downloads/2013_candidate_elected.dta", clear 

drop if edu_level == . 

count if eletto == 1 & coalition == "CDX" //ELECTED CENTRE-RIGHT
count if eletto == 0 & coalition == "CDX" //NON-ELECTED CENTRE-RIGHT

count if eletto == 1 & male == 1 & coalition == "CDX" //82% MEN ELECTED CENTRE-RIGHT
count if eletto == 1 & male == 0 & coalition == "CDX" //18% WOMEN ELECTED CENTRE-RIGHT
count if eletto == 0 & male == 1 & coalition == "CDX" //84% MEN NON-ELECTED CENTRE-RIGHT
count if eletto == 0 & male == 0 & coalition == "CDX" //16% WOMEN NON-ELECTED CENTRE-RIGHT 

//PANEL A, WOMEN
count if eletto == 0 & male == 0 & hi_edu == 1 & coalition == "CDX" //58% WOMEN NON-ELECTED, HIGH EDU, CENTRE-RIGHT
count if eletto == 0 & male == 0 & lo_edu == 1 & coalition == "CDX" //42% WOMEN NON-ELECTED, LOW EDU, CENTRE-RIGHT
count if eletto == 1 & male == 0 & hi_edu == 1 & coalition == "CDX" //57% WOMEN ELECTED, HIGH EDU, CENTRE-RIGHT
count if eletto == 1 & male == 0 & lo_edu == 1 & coalition == "CDX" //43% WOMEN ELECTED, LOW EDU, CENTRE-RIGHT

//PANEL B, MEN
count if eletto == 0 & male == 1 & hi_edu == 1 & coalition == "CDX" //51% MEN NON-ELECTED, HIGH EDU, CENTRE-RIGHT
count if eletto == 0 & male == 1 & lo_edu == 1 & coalition == "CDX" //49% MEN NON-ELECTED, LOW EDU, CENTRE-RIGHT
count if eletto == 1 & male == 1 & hi_edu == 1 & coalition == "CDX" //73% MEN ELECTED, HIGH EDU, CENTRE-RIGHT
count if eletto == 1 & male == 1 & lo_edu == 1 & coalition == "CDX" //27%  MEN ELECTED, LOW EDU, CENTRE-RIGHT


*TABLE A11 - BALLOT POSITION AND EDUCATION

use "~/Downloads/2013_candidate_elected.dta", clear 
cd "~/Downloads"

reg n_list i.hi_edu##i.male //NB: DV is list position, so a negative coefficient means a positive effect on list position (i.e. a smaller number)
* outreg2 using list_edu, tex replace nocons dec(3) pdec(3)

reg n_list i.hi_edu##i.male
margins hi_edu#male  //marginal effects


***FIGURES

*FIGURE A1

use "~/Downloads/aggregate_candidate.dta", clear 
cd "~/Downloads"

graph bar sh_f_cand, over(year) blabel(total) scheme(plotplain) blabel(total, format(%4.3f)) 
* graph save "Graph" "/Users/elliewoodhouse/Downloads/FigureA1.gph", replace 


*FIGURE A2

use "~/Downloads/dual_tier.dta", clear 
cd "~/Downloads"

graph bar share_f, over(race) over(year) blabel(total) scheme(plotplain) blabel(total, format(%4.3f)) 
* graph save "Graph" "/Users/elliewoodhouse/Downloads/FigureA2.gph", replace 


*FIGURES A3-A5

use "~/Downloads/1987_2013_elected.dta", clear 
cd "~/Downloads"
xtset ID year

//EDUCATION
preserve
gen educ_new = .
replace educ_new = 1 if edu_le <3
replace educ_new = 2 if edu_l == 3
replace educ_new = 3 if edu_l > 3
collapse (count) ID, by(year educ_new)
sort year 
joinby year using "~/Downloads/aggregate_elected.dta", unmatched(none) _merge(_num_inds)
gen pc = ID / year_total
drop if year <1997
twoway connected pc year if edu == 1 || ///
connected pc year if edu == 2 || ///
connected pc year if edu == 3 || ///
||, legend (label(1 "primary school") label(2 "secondary school") label(3 "degree and above")) xline(2005) title("EDUCATION OF POLITICIANS") scheme(plotplain)
* graph save Graph "~/Downloads/FigureA3.gph", replace 
restore 

//AGE
preserve
gen first = 0
bysort ID (year): replace first = 1 if _n == 1
gen age_first = dyn_age if first == 1
gen age_group = .
replace age_group = 1 if age_first  < 35
replace age_group = 2 if age_first >= 35 & age_first < 55
replace age_group = 3 if age_first >= 55
replace age_group = . if age_first == .
bysort ID: egen age_group_max = max(age_group)
collapse (count) ID, by(year age_group_max)
joinby year using "~/Downloads/aggregate_elected.dta", unmatched(none) _merge(_num_inds)
gen pc = ID / year_total
drop if year <1997
twoway connected pc year if age_group_max == 1 || ///
connected pc year if age_group_max == 2 || ///
connected pc year if age_group_max == 3 ///
||, legend (label(1 "<35") label(2 "35-55") label(3 ">55")) xline(2005) title("AGE OF POLITICIANS") scheme(plotplain)
* graph save Graph "~/Downloads/FigureA4.gph", replace 
restore 

//PARTY
preserve
collapse (count) ID, by(year dyn_party_ideol)
joinby year using "~/Downloads/aggregate_elected.dta", unmatched(none) _merge(_num_inds)
gen pc = ID / year_total
drop if year <1997
twoway connected pc year if dyn_party_ideol == 1 || ///
connected pc year if dyn_party_ideol == 2 || ///
connected pc year if dyn_party_ideol == 3 || ///
connected pc year if dyn_party_ideol == 4 || ///
connected pc year if dyn_party_ideol == 5 || ///
connected pc year if dyn_party_ideol == 98 || ///
||, legend (label(1 "left") label(2 "centre-left") label(3 "centre") label(4 "centre-right") label(5 "right") label(6 "autonomous")) xline(2005) title("PARTY AFFILIATION OF POLITICIANS") scheme(plotplain)
* graph save Graph "~/Downloads/FigureA5.gph", replace 
restore


*FIGURE A6

use "~/Downloads/2013_candidate_elected.dta", clear 
cd "~/Downloads"

drop if edu_level == 5 //getting rid of 2x obs that make graph more difficult to read, Enrico Letta

twoway kdensity edu_level if male == 0 & eletto == 0 & north == 1, bw(0.6) || kdensity edu_lev if male == 1 & eletto== 0 & north == 1, bw(0.6) /// 
|| kdensity edu_lev if male == 0 & eletto== 1 & north == 1, bw(0.6) || kdensity edu_lev if male == 1 & eletto== 1 & north == 1, bw(0.6) scheme(plotplain) legend(ring(0) pos(11) ///
 label(1 "women cand.") label(2 "men cand.") label(3 "women elect.") label(4 "men elect.")) title("PANEL A: NORTHERN REGION: 2013")    name(kernel3, replace)

twoway kdensity edu_level if male == 0 & eletto == 0 & south == 1, bw(0.6) || kdensity edu_lev if male == 1 & eletto== 0 & south == 1, bw(0.6) /// 
|| kdensity edu_lev if male == 0 & eletto== 1 & south == 1, bw(0.6) || kdensity edu_lev if male == 1 & eletto== 1 & south == 1, bw(0.6) scheme(plotplain) legend(ring(0) pos(11) ///
 label(1 "women cand.") label(2 "men cand.") label(3 "women elect.") label(4 "men elect.")) title("PANEL B: SOUTHERN REGION: 2013")    name(kernel4, replace)

graph combine kernel3 kernel4
* graph save Graph "~/Downloads/FigureA6.gph", replace 
